import os,sys,pytest
from selenium import webdriver
import time
url="https://p-iot.hang-shu.com/#/login"
def webui(uname,pwd,chkcode):
    driver=webdriver.Chrome()
    driver.implicitly_wait(10)
    driver.get(url)
    driver.maximize_window()
    if uname!=None:
        driver.find_element_by_css_selector('input[placeholder="账号"]').send_keys(uname)
    if pwd!=None:
        driver.find_element_by_css_selector('input[placeholder="密码"]').send_keys(pwd)
    if chkcode!=None:
        driver.find_element_by_css_selector('input[placeholder="验证码"]').send_keys(chkcode)
    driver.find_element_by_css_selector('button[class="el-button btn_login el-button--default el-button--medium"]').click()
    time.sleep(1)
    # alertext=driver.switch_to.alert.text
    # alertext=driver.switch_to_alert().text
    #p[class="el-message__content"]
    try:
        alertext =driver.find_element_by_css_selector('p[class="el-message__content"]').text
        print(alertext)
        driver.quit()
        return alertext
    except  Exception as e:
        print("报错了，内容：",e)
        return e
    # driver.switch_to.frame()
    # print("guoguoguoguoguoguoguoguoguoguoguoguo")

    # driver.quit()




